#include<bits/stdc++.h>
//#define int long long
using namespace std;
// const int N=10005;
int P,T;
int n,m;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
void write(int x)
{
    if(x<0){putchar('-'),x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
    return;
}

signed main()
{
    freopen("pr.in","r",stdin);
    freopen("pr.out","w",stdout);
    int P,T,n,m;
    P=read();
    T=read();
    for(int i=1;i<=T;i++)
    {
        n=read(),m=read();
        int cnt;
        cnt=P*((n+m)/pow(m+1,2*n));
        write(cnt);
        putchar('\n');
    }
    return 0;
}
